package com.panfeng.xcloud.boss.provider.member.service.impl;

import com.panfeng.xcloud.boss.provider.member.service.IUploadService;
import com.panfeng.xcloud.component.oss.OssMaker;
import com.panfeng.xcloud.component.oss.model.UploadResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 *
 * 上传服务
 *
 * @author xiaobo
 * @version 1.0
 * @since 2019-08-13
 */
@Service
public class UploadServiceImpl implements IUploadService {

    @Autowired
    private OssMaker ossMaker;

    /**
     * 图片上传
     * @param multipartFile
     * @return
     */
    @Override
    public UploadResult imgUpload(MultipartFile multipartFile) {
        try {
            UploadResult uploadResult = ossMaker.uploadFile(multipartFile.getOriginalFilename(), multipartFile.getInputStream());
            return uploadResult;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
